home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / programming / e / lsestuff / test.e < prev    next >
Text File  |  1999-11-29  |  1KB  |  49 lines

  1. MODULE '*dynamic_array'
  2.  
  3. PROC main() HANDLE
  4.    DEF a, b, da:PTR TO dynamic_array
  5.    NEW da
  6.    da.dynamic_array(DAVS_INT, 256)
  7.    WriteF('dynamic ARRAY OF INT, speedval=256\n')
  8.    Execute('run date', NIL, NIL)
  9.    WriteF('getting 5 000 empty points\n')
  10.    FOR a:=0 TO 4999
  11.       b:=da.get(a)
  12.    ENDFOR
  13.    Execute('run date', NIL, NIL)
  14.    WriteF('setting 5 000 points\n')
  15.    FOR a:=0 TO 4999
  16.       da.set(a, a)
  17.    ENDFOR
  18.    Execute('run date', NIL, NIL)
  19.    WriteF('counting points : \d\n', da.count())
  20.    Execute('run date', NIL, NIL)
  21.    WriteF('setting the same 5 000 points again\n')
  22.    FOR a:=4999 TO 0 STEP -1
  23.       da.set(a, a)
  24.    ENDFOR
  25.    Execute('run date', NIL, NIL)
  26.    WriteF('getting 5 000 points\n')
  27.    FOR a:=0 TO 4999
  28.       b:=da.get(a)
  29.       IF b<>a THEN WriteF('\d=\d\n', a, b)
  30.    ENDFOR
  31.    Execute('run date', NIL, NIL)
  32.    WriteF('memory available now : \d\n', AvailMem(NIL))
  33.    Execute('run date', NIL, NIL)
  34.    WriteF('unsetting 5 000 points\n')
  35.    FOR a:=0 TO 4999
  36.       da.unset(a)
  37.    ENDFOR
  38.    Execute('run date', NIL, NIL)
  39.    WriteF('memory available now : \d\n', AvailMem(NIL))
  40.    WriteF('counting values (should be 0) : \d\n', da.count())
  41.    WriteF('finnished!\n')
  42.  
  43. EXCEPT DO
  44.    IF exception="MEM" THEN WriteF('memerror!\n')
  45.    IF exception="NIL" THEN WriteF('NIL at line : \d\n', exceptioninfo)
  46.    END da
  47. ENDPROC
  48.  
  49.